import {Component, OnDestroy, OnInit, ViewChild} from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router';
import {DatePipe} from '@angular/common';
import {Model} from '../../../entity/model.model';
import {Tag} from '../../../entity/tag.model';
import {TurboperCategory} from '../../../entity/turboper-category.model';
import {TurboperCategoryService} from '../../../service/turboper-category.service'
import {WindPowers} from '../../../entity/wind-powers.model';
import {ModelService} from '../../../service/model.service';
import {TurbStatusService} from '../../../service/turbstatus.service';
import {WindPowersService} from '../../../service/wind-powers.service';
import {TurbStatus} from '../../../entity/turbstatus.model';
import {TagData} from '../../../entity/tag-data.model';
import {TurbineStatus} from './turbineStatus.model';
import {AlarmListDetailComponent} from './alarm-list/alarm-list.component';
import {DataSourceService} from '../../../service/data-source/data-source.service';
import {ApplicationService} from '../../../service/application.service';
import {TurbcomponentService} from '../../../service/turbcomponent.service';
import {TurbComponent} from '../../../entity/turbcomponent.model';
import {ModelParamService} from '../../../service/model-param.service';
import {ModelParam} from '../../../entity/model-Param';
import {FarmCategoryEnum} from '../../common/device-tag-selector/farm-category.enum';
import {DeviceCategoryEnum} from '../../common/device-tag-selector/device-category.enum';
import {Device} from '../../../entity/device.model';
import {DeviceService} from '../../../service/device.service';
import {NzMessageService} from 'ng-zorro-antd';
import {InterceptorService} from '../../../service/interceptor/interceptor-service';

@Component({
  selector: 'app-turbine-detail',
  templateUrl: './turbine-detail.component.html',
  styleUrls: ['./turbine-detail.component.css'],
})
export class TurbineDetailComponent implements OnInit, OnDestroy {
  generatorTitle: string;
  gearBoxTitle: string;
  variableTitle: string;
  yawTitle: string;
  public farmCategory: FarmCategoryEnum = FarmCategoryEnum.winfarm;
  public deviceCategories: DeviceCategoryEnum[] = [DeviceCategoryEnum.turbine];
  /**
   * 数据源服务
   *
   * @private
   * @type {DataSourceService}
   * @memberof TurbineListComponent
   */
  private dataSource: DataSourceService;

  @ViewChild(AlarmListDetailComponent, {static: true})
  AlarmList: AlarmListDetailComponent;
  private models: Model[] = [];
  /**
   * 当前风场风机的model信息
   *
   * @type {Model}@memberof TurbineDetailComponent
   */
  public turbineModel: Model;
  /**
   * 当前风场风机
   *
   * @type {Turbine}@memberof TurbineDetailComponent
   */
  public currentDevice: Device;
  /**
   * 是否显示风机选择组件
   *
   * @type {boolean}@memberof TurbineDetailComponent
   */
  public showSelector: boolean = false;
  /**
   * 当前header选中下标
   *
   * @type {boolean}@memberof TurbineDetailComponent
   */
  private active: number = 0;
  public selectedFarmId: number = 0;
  public selectedDeviceId: number = 0;
  /**
   * 风机状态集合
   *
   * @type {TurbId}@memberof TurbineDetailComponent
   */
  private turbineStatus: TurbStatus[] = [];
  /**
   * 风机状态
   *
   * @type {TurbStatus}@memberof TurbineDetailComponent
   */
  public currentStatus: TurbStatus;
  /**
   * 滑过的风机系统
   *
   * @type {any}@memberof TurbineDetailComponent
   */
  public n: any = false;
  //public options: optionsData;

  /**
   * 风功率echarts series
   *
   * @type {seriesData[]}@memberof TurbineDetailComponent
   */
  //public series: seriesData[] = [];

  /**
   * 风功率echarts y轴
   *
   * @type {object}@memberof TurbineDetailComponent
   */
  // public yAxis: yAxisData;
  /**
   * 型号信息
   *
   * @private
   * @type {ModelParam[]}
   * @memberof TurbineDetailComponent
   */
  public modelParams: ModelParam[] = [];
  /**
   * 当前风机的测点信息
   *
   * @type {object}@memberof TurbineDetailComponent
   */
  private tags: Tag[] = [];
  /**
   * 发电机系统数据
   *
   * @type {TagData[]}
   * @memberof TurbineDetailComponent
   */
  generator: TagData[] = [];
  /**
   * 是否展示发电机系统数据
   *
   * @type {boolean}
   * @memberof TurbineDetailComponent
   */
  isShowGenerator: boolean;
  /**
   * 发电机系统图标
   *
   * @type {Images}
   * @memberof TurbineDetailComponent
   */
  generatorIcon: Images;
  /**
   * 齿轮箱系统数据
   *
   * @type {TagData[]}
   * @memberof TurbineDetailComponent
   */
  gearBox: TagData[] = [];
  /**
   * 是否展示齿轮箱系统
   *
   * @type {boolean}
   * @memberof TurbineDetailComponent
   */
  isShowGearBox: boolean;
  /**
   * 齿轮箱系统图标
   *
   * @type {Images}
   * @memberof TurbineDetailComponent
   */
  gearBoxIcon: Images;
  /**
   * 偏航系统数据
   *
   * @type {TagData[]}
   * @memberof TurbineDetailComponent
   */
  yaw: TagData[] = [];
  /**
   * 是否展示偏航系统
   *
   * @type {boolean}
   * @memberof TurbineDetailComponent
   */
  isShowYaw: boolean;
  /**
   * 偏航系统图标
   *
   * @type {Images}
   * @memberof TurbineDetailComponent
   */
  yawIcon: Images;
  /**
   * 变桨系统数据
   *
   * @type {TagData[]}
   * @memberof TurbineDetailComponent
   */
  variable: TagData[] = [];
  /**
   * 是否显示变桨系统
   *
   * @type {boolean}
   * @memberof TurbineDetailComponent
   */
  isShowVariable: boolean;
  /**
   * 变桨系统图标
   *
   * @type {Images}
   * @memberof TurbineDetailComponent
   */
  variableIcon: Images;
  /**
   * 当前风机状态
   *
   * @type {TagData}
   * @memberof TurbineDetailComponent
   */
  subState: TagData;
  /**
   * 风机子状态集合
   *
   * @private
   * @type {TurboperCategory[]}
   * @memberof TurbineDetailComponent
   */
  private turboperCategorys: TurboperCategory[] = [];
  /**
   * 风机状态集合
   *
   * @type {TurbineStatus[]}
   * @memberof TurbineDetailComponent
   */
  public turbineStatuses: TurbineStatus[] = [];
  /**
   * 当前风机子状态
   *
   * @type {TurboperCategory}
   * @memberof TurbineDetailComponent
   */
  public currentTurbSub: TurboperCategory;

  //private result: Tag[] = [];
  /**
   * 风功率数据集合
   *
   * @private
   * @type {WindPowers[]}
   * @memberof TurbineDetailComponent
   */
  private windPowers: WindPowers[] = [];
  /**
   * 标准风功率数据集合
   *
   * @private
   * @type {number[][]}
   * @memberof TurbineDetailComponent
   */
  private standardWindPowers: number[][] = [];
  /**
   * 历史风功率曲线集合
   *
   * @private
   * @type {number[][]}
   * @memberof TurbineDetailComponent
   */
  private historyWindPowers: number[][] = [];
  private faultActive: boolean = false;
  private basicInfoCode: number = 15;
  private timer: any = null;
  private echartsIntance: any = null;
  /**
   * 基本信息数据
   *
   * @type {TagData[]}@memberof TurbineDetailComponent
   */
  public basicData: TagData[] = [];
  public total: TurbineDetail[] = [];
  private isShow: boolean = false;
  private turbineCImage: TurbineCImage[] = [
    {
      valueCode: 1,//发电机
      images: ['engine3.png', 'generator.png', 'engine.png', 'engine2.png'],
    },
    {
      valueCode: 16,//齿轮箱
      images: ['gear3.png', 'gear-box.png', 'gear.png', 'gear2.png'],
    },
    {
      valueCode: 6, //变浆系统
      images: ['network3.png', 'variable.png', 'network.png', 'network2.png'],
    },
    {
      valueCode: 8, //风轮
      images: ['windwheel2.png', 'windwheel.png', 'windwheel4.png', 'windwheel3.png'],
    },
    {
      valueCode: 9, //液压系统
      images: ['hydraulic3.png', 'hydraulic.png', 'hydraulic1.png', 'hydraulic2.png'],
    },
    {
      valueCode: 4, //偏航系统
      images: ['centre3.png', 'yaw.png', 'centre.png', 'centre2.png'],
    },
    {
      valueCode: 14, //其他系统
      images: ['categorize3.png', 'categorize1.png', 'categorize.png', 'categorize2.png'],
    },
    {
      valueCode: 5, //变频器
      images: ['cogs3.png', 'conversion.jpg', 'cogs.png', 'cogs2.png'],
    },
    {
      valueCode: 11, //电池系统
      images: ['battery3.png', 'battery.png', 'battery1.png', 'battery2.png'],
    },
    {
      valueCode: 17, // 震动系统
      images: ['vibration3.png', 'vibration.png', 'vibration1.png', 'vibration2.png'],
    },
    {
      valueCode: 18, // 箱变系统
      images: ['packaged2.png', 'packaged.png', 'packaged4.png', 'packaged3.png'],
    },
    {
      valueCode: 680, // 变流系统
      images: ['transformer2.png', , 'transformer4.png', 'transformer3.png'],
    }
  ];
  turbineComponents: TurbComponent[] = [];
  /* private images: string[][] = [


    ,//液压
    ,//偏航
    ,//其他
    [],
    ,//变频
    ,//电池
    // 震动
  ] */
  /**
   * 开关量为1时颜色
   *
   * @type {string}
   * @memberof TurbineDetailComponent
   */
  switchingValue1 = '#008000';
  /**
   * 开关量为0时颜色
   *
   * @type {string}
   * @memberof TurbineDetailComponent
   */
  switchingValue2 = '#FFFF00';

  constructor(
    private http: InterceptorService,
    private datePipe: DatePipe,
    private application: ApplicationService,
    private modelService: ModelService,
    private TurbStatusService: TurbStatusService,
    private windPowersService: WindPowersService,
    private router: Router,
    private activatedRoute: ActivatedRoute,
    private turbcompSer: TurbcomponentService,
    private turbCategorySer: TurboperCategoryService,
    private modelParamSer: ModelParamService,
    private deviceService: DeviceService,
    private _message: NzMessageService
  ) {


  }

  private curWwwPath: string;
  private pathName: string;
  private pos: number;
  public localhostPath: string;

  public ngOnInit() {
    if (this.application.currentApplicationParams && this.application.currentApplicationParams['switchingValue1']) {
      this.switchingValue1 = this.application.currentApplicationParams['switchingValue1'].paramValue;
    }
    if (this.application.currentApplicationParams && this.application.currentApplicationParams['switchingValue2']) {
      this.switchingValue2 = this.application.currentApplicationParams['switchingValue2'].paramValue;
    }
    this.turbCategorySer.getTurboperCategorys()
      .then(res => {
        if (!res) {
          return false;
        }
        this.turboperCategorys = [...res];
      })
      .catch(err => {
        if (this.application.appConfigData.isShowErr) {
          this._message.info('风机操作列表获取数据失败', {nzDuration: 3000});
        }
        //console.log(err)
      })
    this.curWwwPath = window.location.href;
    this.pathName = window.location.pathname;
    this.pos = this.curWwwPath.indexOf(this.pathName);
    this.localhostPath = this.curWwwPath.substring(0, this.pos);
    if (this.localhostPath.indexOf('localhost') < 0) {
      this.localhostPath = this.localhostPath;
    }
    this.activatedRoute.params.subscribe((params: { farmId: number, turbineId: number }) => {
      if (params.farmId != 0 && params.turbineId != 0) {
        this.selectedFarmId = params.farmId;
        this.selectedDeviceId = params.turbineId;
      }
    });
    let models = this.modelService.getModelWithFactory();
    let turbStatus = this.TurbStatusService.getTurbStatus();
    let turbComs = this.turbcompSer.getParentTurbComponents();
    Promise.all([models, turbStatus, turbComs])
      .then(res => {
        if (res[0]) {
          this.models = [...res[0]];
        }
        if (res[1]) {
          this.turbineStatus = [...res[1]];
        }
        if (res[2]) {
          this.turbineComponents = [...res[2]];
        }
        this.setCurrentStatus();
        this.getTurbineModel();
      })
      .catch(err => {
        if (this.application.appConfigData.isShowErr) {
          this._message.info('风机详情数据初始化失败，' + err, {nzDuration: 3000});
        }
      })
  }

  public ngOnDestroy(): void {
    if (this.dataSource != null)
      this.dataSource.dispose();
  }

  setCurrentStatus() {
    if (!this.currentStatus) {
      this.currentStatus = this.turbineStatus.find(o => o.statusValue === 1);
    }
  }

  /**
   * 滑入风机系统tab时显示对应的风机系统

   *
   * @type {}@memberof TurbineDetailComponent
   */
  public onMouseEnter() {
    this.showSelector = true;
  }

  /**
   * 滑出风机系统tab时隐藏对应的风机系统
   *
   * @type {}@memberof TurbineDetailComponent
   */
  public onMouseLeave(ev) {
    if (!ev.toElement) return false;
    this.showSelector = false;
  }

  public onMouseToopEnter(n: number) {
    let index = this.total.findIndex(o => o.valueCode === n);
    if (index > -1) {
      this.onMouseTitleEnter(index, this.total[index].img);
    }
  }

  public onMouseToopLeave(n: number) {
    let index = this.total.findIndex(o => o.valueCode === n);
    if (index > -1) {
      this.onMouseTitleLeave(index, this.total[index].img);
    }
  }

  /**
   * 滑风机图圆点部分时显示对应风机系统
   *
   * @type {}@memberof TurbineDetailComponent
   */
  public onMouseTitleEnter(index: number, img: Images) {
    if (img && img['icon']) {
      let image: string = img.icon;
      img.icon = img.iconHover;
      img.iconHover = image;
    }

    clearTimeout(this.timer);
    this.timer = setTimeout(() => {
      this.n = index;

    }, 300);
    return false;
  }

  onClick(index: number, img: Images) {
    if (this.n !== index) {
      if (this.n !== false && this.total[this.n].img && this.total[this.n].img['icon']) {
        const icon = this.total[this.n].img.icon,
          iconHover = this.total[this.n].img.iconHover;
        this.total[this.n].img.icon = iconHover;
        this.total[this.n].img.iconHover = icon;

      }
      if (img && img['icon']) {
        let image: string = img.icon;
        img.icon = img.iconHover;
        img.iconHover = image;
      }
      this.n = index;
    }

    /*  if (this.n === index) {
       this.n = false;
     } else { */

    //}

    return false;
  }

  /**
   * 滑出风机图圆点部分时隐藏对应风机系统
   *
   * @type {}@memberof TurbineDetailComponent
   */
  public onMouseTitleLeave(index: number, img: Images) {

    clearTimeout(this.timer);
    setTimeout(() => {
      if (img && img.icon) {
        let image: string = img.icon;
        img.icon = img.iconHover;
        img.iconHover = image;
      }
      this.n = false;
    }, 300)

    return false;
  }

  /**
   * 得到风机型号信息
   *
   * @type {}@memberof TurbineDetailComponent
   */
  getTurbineModel() {
    if (!this.models || !this.currentDevice) {
      return false;
    }
    this.modelParamSer.getModelParamsByModeID(this.currentDevice.modelId)
      .then(res => {
        if (res) {
          this.modelParams = [...res];
        }
      });
    let index = this.models.findIndex(o => this.currentDevice && (o.modelId === this.currentDevice.modelId));
    if (index >= 0) this.turbineModel = this.models[index];
    this.windPowersService.getWindPowersByModelId(this.currentDevice.modelId)
      .then(res => {
        if (!res) return false;
        this.windPowers = [...res];
        this.standardWindPowers = [];
        this.windPowers.forEach((value, i) => {
          this.standardWindPowers[i] = [value.wind, value.power]
        });
      }).catch(err => {
      if (this.application.appConfigData.isShowErr) {
        this._message.info('标准风功率曲线' + err, {nzDuration: 3000});
      }

      //console.log(err);
    })

    if (window.sessionStorage.getItem(this.turbineModel.modelId + '')) {
      this.tags = JSON.parse(window.sessionStorage.getItem(this.turbineModel.modelId + ''));
      this.getTurbineCode();
    } else {
      this.modelService.getShowTagByModelId(this.turbineModel.modelId, 4)
        .then(res => {
          if (!res) return false;
          this.tags = [...res];
          window.sessionStorage.setItem(this.turbineModel.modelId + '', JSON.stringify(this.tags));
          this.getTurbineCode();
        })
        .catch(err => {
          if (this.application.appConfigData.isShowErr) {
            this._message.info('风机测点' + err, {nzDuration: 3000});
          }

          //console.log(err);
        })
    }
    /* if (this.yAxis) {
      //this.yAxis.max = this.turbineModel.ratedPower * 1000 + 200;
    } */
  }

  onClickHome() {
    if (this.n !== false) {
      if (this.total[this.n].img && this.total[this.n].img.icon) {
        this.total[this.n].img.iconHover = this.total[this.n].img.icon;
      }
      if (this.total[this.n].img && this.total[this.n].img.iconHover) {
        this.total[this.n].img.icon = this.total[this.n].img.iconHover;
      }
    }
    this.n = false;
  }

  getTurbineCode() {
    this.AlarmList.upData([this.currentDevice.deviceId], new Date(this.datePipe.transform(new Date(), 'yyyy-MM-dd')), new Date());
    this.total = [];
    this.basicData = [];
    let tagDatas: TagData[] = [];
    //注销数据源
    if (this.dataSource != null) {
      this.dataSource.dispose();
    }
    if (this.currentDevice == null)
      return;
    let farmCode = this.currentDevice.farmCode;
    let turbineCode = this.currentDevice.deviceCode;
    this.dataSource = new DataSourceService(this.http, this.datePipe);
    // let subState = this.application.tagDict['GP'];
    let subState = this.application.tagDict['TurbineStatus'];
    this.subState = this.dataSource.binding([farmCode, turbineCode], subState);
    //创建该风机的测点
    this.tags.forEach(tag => {
      let num: number = 0;
      if (tag.tagSet) {
        num = tag.tagSet.indexOf('3') > -1 ? 1 : 0;
      }
      //绑定数据
      let tagData: TagData = this.dataSource.binding([farmCode, turbineCode], tag);
      tagData.tagName = tag.tagName;
      tagData.tagUnit = tag.tagUnit ? '(' + tag.tagUnit + ')' : tag.tagUnit;
      tagData.turbComponent = tag.turbComponentId;
      tagData.tagKind = tag.tagKind;
      tagData.tagSet = num;
      tagDatas.push(tagData);
    });
    if (!this.turbineComponents) return false
    //创建该风机部件以及部件下的测点
    this.turbineComponents.forEach((component, index) => {
      if (component.turbComponentId !== this.basicInfoCode) {
        let img: Images;
        // const i = this.turbineCImage.findIndex(o => o.valueCode == component.turbComponentId);
        if (component.turbComponentIcon) {
          img = {
            icon: component.turbComponentIcon + '.png',
            iconHover: component.turbComponentIcon + 1 + '.png',
            titleImage: component.turbComponentIcon + 2 + '.png',
            bgImage: component.turbComponentIcon + 3 + '.png',
          };
          this.total.push({
            title: component.turbComponentName,
            valueCode: component.turbComponentId,
            data: tagDatas.filter(o => o.turbComponent == component.turbComponentId),
            img: img,
          });
        } else {
          this.total.push({
            title: component.turbComponentName,
            valueCode: component.turbComponentId,
            data: tagDatas.filter(o => o.turbComponent == component.turbComponentId),
            img: img,
          });
        }
      } else {

        this.basicData = tagDatas.filter(o => o.turbComponent == component.turbComponentId);
      }
    });
    let index = this.total.findIndex(o => o.valueCode == 1);
    if (index > -1) {
      this.generator = this.total[index].data.filter(o => o.turbComponent && o.tagSet);
      this.isShowGenerator = this.generator.length > 0 ? true : false;
      this.generatorIcon = this.total[index].img;
      this.generatorTitle = this.total[index].title;
    }

    index = this.total.findIndex(o => o.valueCode == 16);
    if (index > -1) {
      this.gearBox = this.total[index].data.filter(o => o.turbComponent && o.tagSet);
      this.isShowGearBox = this.gearBox.length > 0 ? true : false;
      this.gearBoxIcon = this.total[index].img;
      this.gearBoxTitle = this.total[index].title;
    }

    index = this.total.findIndex(o => o.valueCode == 6);
    if (index > -1) {
      this.variable = this.total[index].data.filter(o => o.turbComponent && o.tagSet);
      this.isShowVariable = this.variable.length > 0 ? true : false;
      this.variableIcon = this.total[index].img;
      this.variableTitle = this.total[index].title;
    }

    index = this.total.findIndex(o => o.valueCode == 4);
    if (index > -1) {
      this.yaw = this.total[index].data.filter(o => o.turbComponent && o.tagSet);
      this.isShowYaw = this.yaw.length > 0 ? true : false;
      this.yawIcon = this.total[index].img;
      this.yawTitle = this.total[index].title;
    }
    let TurbineStatus = this.application.tagDict['TurbineStatus'];
    let start1 = new Date(this.datePipe.transform(new Date(), 'yyyy/MM/dd'));
    let end1 = new Date();
    //获得点名
    let statusCode = this.dataSource.buildTagCode([this.currentDevice.farmCode, this.currentDevice.deviceCode], TurbineStatus);
    this.dataSource.history.getDeviceStatuses([statusCode], start1, end1).then(res => {
      try {
        res.sort(function (a, b) {
          return new Date(b.time).getTime() - new Date(a.time).getTime()
        });
        let turbineStatuses: TurbineStatus[] = [];
        res.forEach((v, i) => {
          let index = this.turbineStatus.findIndex(o => o.statusValue == v.value);
          if (index >= 0) {
            let turbComponentName = this.turbineStatus[index].statusName;
            turbineStatuses.push({
              statusName: turbComponentName, statusValue: v.value, time: v.time,
            })
          } else {
            turbineStatuses.push({
              statusName: this.turbineStatus[0].statusName, statusValue: v.value, time: v.time
            });
          }
        });
        this.turbineStatuses = [...turbineStatuses];
      } catch (error) {
      }
    }).catch(error => {
      if (this.application.appConfigData.isShowErr) {
        this._message.info('获取风机状态历史数据' + error, {nzDuration: 3000});
      }

      //console.log('app-turbine-detail has error', error);
    });
    //开始订阅数据
    this.dataSource.begin().subscribe(next => {
      try {
        if (this.turboperCategorys) {
          let index = this.turboperCategorys.findIndex(o => o.operCategoryCode == this.subState.value.toString());
          if (index > -1) {
            this.currentTurbSub = this.turboperCategorys[index];
          }
        }
        let tagData = next.find(o => o.code.endsWith(TurbineStatus.tagCode));
        if (tagData != null) {

          let i = this.turbineStatus.findIndex(o => o.statusValue == tagData.value);
          if (i >= 0)

            this.currentStatus = this.turbineStatus[i];
        }
      } catch (error) {
        console.log(error)
      }

    }, error => {
      console.log('app-turbine-detail has error', error);
    });
  }

  /* initEcharts() {
    this.yAxis = {
      type: 'value',
      //max: this.turbineModel.ratedPower * 1000 + 200,
      min: 0,
      axisLine: {
        show: true,
        lineStyle: {
          color: '#fff',
          type: 'solid',
          width: 1,
          opacity: 0.2
        },
      },
      splitLine: {
        lineStyle: {
          opacity: 0.2
        }
      },
      axisLabel: {
        show: true,
        textStyle: {
          color: '#fff',
          fontSize: 8,
        },
      },
    }
    this.options = {
      tooltip: {
        trigger: 'axis',
        axisPointer: 'line',
        formatter: (params) => {
          let res = ''
          for (let i = 0; i < params.length; i++) {
            res += params[i].seriesName + ':' + params[i].value[1] + '(kw)</br>'
          };
          return res;
        },
        textStyle: {
          fontStyle: 12,
        }
      },
      xAxis: {
        type: 'value',
        splitLine: {
          lineStyle: {
            opacity: 0.2
          }
        },
        axisLine: {
          show: true,
          lineStyle: {
            color: '#fff',
            type: 'solid',
            width: 1,
            opacity: 0.2
          },
        },
        max: 25,
        min: 0,
        axisLabel: {
          show: true,
          textStyle: {
            color: '#fff',
            fontSize: 8,
          },
        },
      },
      yAxis: this.yAxis,
      grid: {
        top: 10,
        bottom: 20,
        left: 30,
        right: 10
      },
      series: this.series
    };
  }
  onChartInit(ec: any) {
    this.echartsIntance = ec;
  } */
  /**
   * 更新echarts实例数据
   *
   *
   * @memberof TurbineDetailComponent
   */

  /* updateEchart() {
    if (this.echartsIntance != null) {
      this.options.series = this.series;
      this.options.yAxis = this.yAxis;
      this.echartsIntance.setOption(this.options);
    };
  } */
  faultClick(bool: boolean) {
    this.faultActive = bool;
  }

  private tabIsShow(ev: any) {
    this.isShow = false;
  }

  onSelectFarmRadio(ev: Device[]) {
    this.currentDevice = ev[0];
    if (!this.currentDevice.deviceId) return false;
    this.getTurbineModel();
    this.showSelector = false;
  }
}

interface TurbId {
  turbineId: number;
  farmId: number;
}

interface TurbineDetail {
  title: string;
  valueCode: number;
  data?: TagData[];
  img?: Images;

}

interface Images {
  icon?: string;
  iconHover?: string;
  titleImage?: string;
  bgImage?: string;
}

interface optionsData {
  tooltip: object;
  grid: object;
  xAxis: object;
  yAxis: yAxisData;
  series: seriesData[];
}

interface seriesData {
  name: string;
  type: string;
  smooth?: boolean;
  data: number[][];
  label?: object;
  symbolSize?: number;
  itemStyle?: object;
  showSymbol?: boolean;


}

interface yAxisData {
  type: string;
  splitLine?: object;
  axisLine?: object;
  axisLabel?: object;
  boundaryGap?: boolean;
  max?: number;
  min?: number;
  name?: string;
}

interface TurbineCImage {
  valueCode: number;
  images: string[];
}
